<#assign ctx = request.contextPath />
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
  	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
  	<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">
  	<title>加油站系统登陆</title>
	<link href="${ctx}/assets/css/login.css" rel="stylesheet" />
	<link rel="shortcut icon" type="image/x-icon" href="${ctx}/assets/img/ezu.png" />
</head>

<body onkeydown="on_return();">
	<div class="nav">
		<div class="nav-title">
			<h1>加油站登录</h1>
		</div>
		<form id="login_form" action="#" method="post" autocomplete="off">
			<div class="nav-text">
				<img src="${ctx}/assets/img/login-two-tb.png" style="float: left;"/>
				<input  class="thick" type="text"  id="username" name="username" placeholder="用户名" autocomplete="off" required/>
			</div>
			<div class="nav-text-mima">
				<img src="${ctx}/assets/img/login-two-mima.png"  style="float: left;"/>
				<input  class="thick" type="password" id="password" name="password" placeholder="密码" autocomplete="off" required/>
			</div>
			<div class="nav-verification">
				<img src="${ctx}/assets/img/login-two-vt.png" style="float: left; margin-top: 10px; "/>
				<input class="thick" type="text" name="captcha" placeholder="验证码" style="margin-top: 5px; margin-bottom: 5px;" required />
				<img id="captcha" src="${ctx}/captcha" style="float:right;margin-top: -19px;width: 130px; height: 57px;" />
			</div>
			<a id="login_button" class="button-a" href="javascript:;">
				<div class="button">
					<h2>登录</h2>
				</div>
			</a>
			<div id="error_message" class="button-text"></div>
		</form>
    </div>
</body>

<script src="${ctx}/assets/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
	<#if shiroLoginFailure??>
		<#if shiroLoginFailure == "org.apache.shiro.authc.pam.UnsupportedTokenException">
			$("#error_message").html("验证码错误");
		<#elseif shiroLoginFailure == "com.ybkj.daijia.server.exception.DebtsErrorException">
			window.location="${ctx}/debts";
		</#if>
	</#if>
	
	$("#captcha").click(function(){
		$(this).prop('src','${ctx}/captcha?t=' + new Date().getTime());
	});
	
	var num=GetRandomBg(1,3);
	$("body").attr("background","${ctx}/assets/img/bj-"+num+".jpg");
	
	//resize();
	
	//$(window).bind('resize',resize);
	
	$("#login_button").click(function(){
		if($("#username").val()==""){
			$("#error_message").html("请输入用户名");
			return;
		}
		if($("#password").val()==""){
			$("#error_message").html("请输入密码");
			return;
		}
		if($("input[name=captcha]").val()==""){
			$("#error_message").html("请输入验证码");
			return;
		}
		$.post("${ctx}/gaslogin/inLogin",$("#login_form").serialize(),function(data){
				if(data.code==0){
					window.location="${ctx}/gaslogin/gasList";
				}
				else{
				$("#captcha").click();
					$("#error_message").html(data.message);
					//location.reload(true); 
				}
			});		
		
		//$("#login_form").submit();
	});
	
});

function on_return(){
	if(window.event.keyCode == 13){
		$("#login_button").click();
	}
}
 
function resize(){
	//var height=document.documentElement.clientHeight;
	//$("#wrapper").css("height",height);
	//$(".login_box").css("margin-top",(height/2)-297);
}

function GetRandomBg(Min,Max){   
	var Range = Max - Min;   
	var Rand = Math.random();   
	return(Min + Math.round(Rand * Range));   
}   
	
</script>

</html>